#!/usr/bin/env python 
# _*_ coding: utf-8 _*_ 
import base64 
import urllib 
import httplib 
import commands

mt_appkey       = '1238fae55a587fd3eb22e240e422bc6e'
#IN1测试
# data    = '{"isa":"MS2CreditCardPayment","mt_channel2":"CMMM_AXXXXXXXXXX","ms2_uid":"321824681","imei":"testimei","cardno":"4392268316104018","expiry":"0414","cvv2":"068","phone_num":"18601602550","product_index":"cn.morningtec.game.ms2.shortgun","coupon_code":"B3P4E2F8D5A5"}';
#IN2测试
# data    = '{"isa":"MS2BoundCreditCardPayment","mt_channel2":"CMMM_AXXXXXXXXXX","ms2_uid":"321824681","imei":"testimei","cardno_last4":"4018","product_index":"cn.morningtec.game.ms2.shortgun","coupon_code":"B3P4E2F8D5A5"}';
data    = '{"phone_num":"18688964169","imei":"358938041134080","product_index":"com.gamelion.ms2.packedsafe","isa":"MS2CreditCardPayment","cardno":"5201311628886803","ms2_uid":"321824681","cvv2":"061","mt_channel2":"CMGB3G_OFFICIAL","expiry":"0515"}'

data    = commands.getoutput('/Project/hoono/bin/mtcrypto_mac -e -k ' + mt_appkey + " '" + data +"'")

headers = {"Content-type": "application/x-www-form-urlencoded","Accept": "text/plain"}
params  = urllib.urlencode({"mt_appkey": mt_appkey,"data": data})
# conn    = httplib.HTTPConnection("localhost")
conn    = httplib.HTTPConnection("m.morningtec.cn")

conn.request("POST","/hoono/yeepay/request",params,headers)

response        = conn.getresponse() 
#print response.status 
print response.read().strip() 